
import login from '@/views/login/index.vue'
import Layout from '@/layout/index.vue'


const pubilcRoutes = [
    {
        path: '/login',
        name: 'Login',
        component: login,
        meta: {
            title: '登录',
            hidden: true,
            isToken: false
        }
    },
]

const privateRoutes = [
    {
        path: '/',
        name: 'Home',
        component: Layout,
        meta: {
            title: '首页', // 名称
            icon: '', // 图标
            iconActive: '', // 图标激活
            hidden: false, // 是否隐藏
            active: 'home', // 高亮  如果子路由有active，则父路由的active无效
            iconType: 'icon', // image 图片 icon 图标
        },
        children: [
            {
                path: '/',
                name: 'Home',
                component: () => import('@/views/home/index.vue'),
                meta: {
                    title: '首页', // 名称
                    icon: '', // 图标
                    iconActive: '', // 图标激活
                    hidden: false, // 是否隐藏
                    active: 'home', // 高亮  如果子路由有active，则父路由的active无效
                    iconType: 'icon', // image 图片 icon 图标
                }
            }
        ]
    },
    {
        path: '/system',
        name: 'System',
        component: Layout,
        meta: {
            title: '系统管理',
            icon: '',
            iconActive: '',
            hidden: false,
            active: 'system',
            iconType: 'icon',
        },
        children: [
            {
                path: '/user',
                name: 'User',
                component: () => import('@/views/system/user/index.vue'),
                meta: {
                    title: '用户管理',
                    icon: '',
                    iconActive: '',
                    hidden: false,
                    active: 'User',
                    iconType: 'icon',
                }
            },
            {
                path: '/dict',
                name: 'Dict',
                component: () => import('@/views/system/dict/index.vue'),
                meta: {
                    title: '字典管理',
                    icon: '',
                    iconActive: '',
                    hidden: false,
                    active: 'Dict',
                    iconType: 'icon',
                }
            }
        ]
    }
]




const changeRoutes = (routes) => {
    return routes.reduce((pre, cur) => {
        let item = {
            name: cur.name,
            meta: cur.meta,
            path: cur.path
        }
        if (cur.children && cur.children.length > 1) {
            item.children = changeRoutes(cur.children)
        }
        pre.push(item)
        return pre
    }, [])
}

export const routes = changeRoutes(privateRoutes)

export const defaultRoutes = [...pubilcRoutes, ...privateRoutes]
